<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/application/forms/validators/Validator.php';
class MatchValidator extends Validator
{
	public $key1;
	public $key2;
	
	public function __construct(Form &$form, $key1, $key2, $required=false, $message=null)
	{
		$this->isRequired =  $required;
		$this->form       =  $form;
		$this->key        =  $key1;
		$this->key1       =  $key1;
		$this->key2       =  $key2;
		$this->message    =  $message;
		
		// used in validation
		$this->keys = array();
		$this->keys[] = $key1;
		$this->keys[] = $key2;
	}
	
	public function validate()
	{
		if($this->form->{$this->key1} == $this->form->{$this->key2})
		{
			$this->isValid = true;
		}
		else
		{
			$this->isValid  = false;
		}
	}
}
?>